//
// Created by baka on 2025/10/15.
//


#include <stdio.h>
#include "light.h"
#include "adc.h"
#include "cmsis_os.h"
#include "protocol.h"


osThreadId lightTaskHandle;
osMessageQId lightQueueHandle;

void lightTask(void const * argument);

void light_task_init(void)
{
    osThreadDef(lightTask, lightTask, osPriorityNormal, 0, 128);
    lightTaskHandle = osThreadCreate(osThread(lightTask), NULL);
    osMessageQDef(lightQueue, 8, uint32_t);
    lightQueueHandle = osMessageCreate(osMessageQ(lightQueue), NULL);
}

volatile uint32_t ADC_value = 0;
void lightTask(void const * argument)
{

    for (;;)
    {
        get_hum_tem();  //获取温度和湿度
        HAL_ADC_Start(&hadc3);
        if(HAL_ADC_PollForConversion(&hadc3,0xFF) == HAL_OK)
        {
            ADC_value = HAL_ADC_GetValue(&hadc3);
            // xQueueSend(lightQueueHandle,&ADC_value, 0);
        }
        osDelay(1000);
    }
}